var e = require;
var t = module;
var o = exports;
var n = o;
Object.defineProperty(n, "__esModule", {value: !0});
var i = e("BundleNames"),
    a = (function () {
        function e() {}
        return (
            (e.isJSON = function (e) {
                if ("string" == typeof e)
                    try {
                        var t = JSON.parse(e);
                        return !("object" != typeof t || !t);
                    } catch (n) {
                        return !1;
                    }
            }),
            (e.isValidUrl = function (e) {
                return (
                    !!e &&
                    !!/^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\/])+$/.test(e)
                );
            }),
            (e.deepCopy = function (t) {
                if ("object" != typeof t) return t;
                var o = t.constructor == Array ? [] : {};
                if (o instanceof Array)
                    for (var n = 0, i = Object.keys(t); n < i.length; n++) {
                        var a = i[n];
                        o[a] = e.deepCopy(t[a]);
                    }
                else for (var r in t) o[r] = e.deepCopy(t[r]);
                return o;
            }),
            (e.randomFrom = function (e, t) {
                return Math.floor(Math.random() * (t - e + 1) + e);
            }),
            (e.getItem = function (e, t) {
                var o = cc.sys.localStorage.getItem(e);
                return o || (o = null), null === o && t && (o = t), o;
            }),
            (e.setItem = function (e, t) {
                cc.sys.localStorage.setItem(e, t);
            }),
            (e.getTodayStr = function () {
                var e = new Date();
                return e.setTime(e.getTime()), e.getFullYear() + "-" + (e.getMonth() + 1) + "-" + e.getDate();
            }),
            (e.getSeconds = function () {
                var e = new Date();
                return Math.floor(e.getTime() / 1e3);
            }),
            (e.objKeySort = function (e) {
                for (var t = Object.keys(e).sort(), o = {}, n = 0; n < t.length; n++) o[t[n]] = e[t[n]];
                return o;
            }),
            (e.md5 = function (e) {
                return window.md5(e);
            }),
            (e.objectFormat = function (e) {
                var t = "";
                for (var o in e) t.length > 0 ? (t += "," + o + "=" + e[o]) : (t = o + "=" + e[o]);
                return t;
            }),
            (e.parseObject = function (e) {
                if (!e || e.length <= 0) return null;
                for (var t = {}, o = e.split(","), n = 0; n < o.length; n++) {
                    var i = o[n].split("="),
                        a = i[0],
                        r = i[1];
                    a && r && (t[a] = r);
                }
                return t;
            }),
            (e.shuffle = function (e) {
                for (var t = e.length - 1; t >= 0; t--) {
                    var o = Math.floor(Math.random() * (t + 1)),
                        n = e[o];
                    (e[o] = e[t]), (e[t] = n);
                }
                return e;
            }),
            (e.extractWithout = function (t, o, n) {
                for (var i = []; i.length < n; ) {
                    var a = e.randomFrom(t, o);
                    -1 === i.indexOf(a) && i.push(a);
                }
                return i;
            }),
            (e.getSpriteFrame = function (e, t) {
                return game.BundleManager.instance.getBundle(e).get(t, cc.SpriteFrame);
            }),
            (e.getGameBundleSpriteFrame = function (e) {
                return game.BundleManager.instance.getBundle(i.default.Game).get(e, cc.SpriteFrame);
            }),
            (e.startDayTimestamp = function () {
                return new Date(new Date(new Date().toLocaleDateString()).getTime()).getTime();
            }),
            (e.countDownPase = function (e) {
                return (e = Math.floor(e)), "0" + Math.floor(e / 60) + ":" + (e % 60 < 10 ? "0" + (e % 60) : e % 60);
            }),
            (e.updateMaterialState = function (t, o) {
                var n = t.getComponent(cc.RenderComponent);
                n && e.switchGrayMaterial(o, n);
                for (var i = 0; i < t.children.length; i++) e.updateMaterialState(t.children[i], o);
            }),
            (e.switchGrayMaterial = function (e, t) {
                var o = null;
                e
                    ? ((o = cc.Material.getBuiltinMaterial("2d-gray-sprite")), (o = cc.MaterialVariant.create(o, t)))
                    : ((o = cc.Material.getBuiltinMaterial("2d-sprite")), (o = cc.MaterialVariant.create(o, t))),
                    t.setMaterial(0, o);
            }),
            e
        );
    })();
n.default = a;
